home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16.lha / Python-1.6 / Lib / Python1.6 / distutils / command / bdist_dumb.py < prev    next >
Encoding:
Python Source  |  2000-08-05  |  2.8 KB  |  90 lines

  1. """distutils.command.bdist_dumb
  2.  
  3. Implements the Distutils 'bdist_dumb' command (create a "dumb" built
  4. distribution -- i.e., just an archive to be unpacked under $prefix or
  5. $exec_prefix)."""
  6.  
  7. # created 2000/03/29, Greg Ward
  8.  
  9. __revision__ = "$Id: bdist_dumb.py,v 1.10 2000/08/05 01:31:54 gward Exp $"
  10.  
  11. import os
  12. from distutils.core import Command
  13. from distutils.util import get_platform
  14. from distutils.dir_util import create_tree, remove_tree
  15. from distutils.errors import *
  16.  
  17. class bdist_dumb (Command):
  18.  
  19.     description = "create a \"dumb\" built distribution"
  20.  
  21.     user_options = [('bdist-dir=', 'd',
  22.                      "temporary directory for creating the distribution"),
  23.                     ('format=', 'f',
  24.                      "archive format to create (tar, ztar, gztar, zip)"),
  25.                     ('keep-tree', 'k',
  26.                      "keep the pseudo-installation tree around after " +
  27.                      "creating the distribution archive"),
  28.                     ('dist-dir=', 'd',
  29.                      "directory to put final built distributions in"),
  30.                    ]
  31.  
  32.     default_format = { 'posix': 'gztar',
  33.                        'nt': 'zip', }
  34.  
  35.  
  36.     def initialize_options (self):
  37.         self.bdist_dir = None
  38.         self.format = None
  39.         self.keep_tree = 0
  40.         self.dist_dir = None
  41.  
  42.     # initialize_options()
  43.  
  44.  
  45.     def finalize_options (self):
  46.         if self.bdist_dir is None:
  47.             bdist_base = self.get_finalized_command('bdist').bdist_base
  48.             self.bdist_dir = os.path.join(bdist_base, 'dumb')
  49.  
  50.         if self.format is None:
  51.             try:
  52.                 self.format = self.default_format[os.name]
  53.             except KeyError:
  54.                 raise DistutilsPlatformError, \
  55.                       ("don't know how to create dumb built distributions " +
  56.                        "on platform %s") % os.name
  57.  
  58.         self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
  59.  
  60.     # finalize_options()
  61.  
  62.  
  63.     def run (self):
  64.  
  65.         self.run_command ('build')
  66.  
  67.         install = self.reinitialize_command('install')
  68.         install.root = self.bdist_dir
  69.  
  70.         self.announce ("installing to %s" % self.bdist_dir)
  71.         install.ensure_finalized()
  72.         install.run()
  73.  
  74.         # And make an archive relative to the root of the
  75.         # pseudo-installation tree.
  76.         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
  77.                                       get_platform())
  78.         print "self.bdist_dir = %s" % self.bdist_dir
  79.         print "self.format = %s" % self.format
  80.         self.make_archive (os.path.join(self.dist_dir, archive_basename),
  81.                            self.format,
  82.                            root_dir=self.bdist_dir)
  83.  
  84.         if not self.keep_tree:
  85.             remove_tree (self.bdist_dir, self.verbose, self.dry_run)
  86.  
  87.     # run()
  88.  
  89. # class bdist_dumb
  90.